﻿@model List<SuperiorModel.ShippingTemplateModel>
@{
    ViewBag.Title = "运费模板管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<input type="hidden" id="mapRotute" map="map_set" />
<div class="title_ding">

    <p id="location">
        当前位置：
        运费模板管理
    </p>
</div>
<div class="shopmain">
    <div class="shopbody">
        <div class="layui-card">
            @*<div class="layui-card-header">商城管理</div>*@
            <div class="layui-card-body">
                <blockquote class="layui-elem-quote layui-quote-nm">注：请填写实际数值，区域等信息，因数值不准造成的运费问题自行负责，区域如果不全，系统运费计算会默认包邮。</blockquote>
                <div class="layui-form-item">
                    @*<label class="layui-form-label">版本</label>*@
                    <div class="layui-input-block" style="float:left; margin-left:0px;">
                        <button type="button" class="layui-btn" id="btn_addTemplate">新增模板</button>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text" id="dataList">
                    <table class="layui-table" lay-filter="test">
                        <thead>
                            <tr>
                                <th>模板ID</th>
                                <th>模板名称</th>
                                <th>计费方式</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>@item.Id</td>
                                    <td>@item.ShippingTemplatesName</td>
                                    <td>
                                        @switch (item.ChargType)
                                        {
                                            case 1:
                                                <span style="color:green">按件数</span>
                                                break;
                                            case 2:
                                                <span style="color:green">按重量</span>
                                                break;
                                        }
                                    </td>
                                    <td>@item.CreateTime</td>
                                   
                                    <td>
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini" href="/Set/EditSt?id=@item.Id">编辑</a>
                                    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini delTemplate" href="javascript:void(0);" OptionId="@item.Id">删除</a></td>

                                </tr>
                            }
                        </tbody>
                    </table>
                </div>


            </div>
        </div>
    </div>
</div>

<script>
    $(document).on('click', '#btn_addTemplate', function () {
        window.location.href = "/Set/Add";
    })
    $(document).on('click', '.delTemplate', function () {
        var id = $(this).attr("OptionId");
        layer.confirm('删除后数据不可恢复，确定要执行吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            var index = layer.load(1);
            $.get("/Set/DelTemplate?id=" + id + "&r=" + new Date().getTime(), function (data) {
                layer.close(index);
                if (data.IsSuccess) {
                    layer.alert("执行成功", function () {
                        window.location.href = "/Set/ShippingTemplateList";
                    })

                } else {
                    layer.alert(data.Message);
                }
            })
        }, function () {

        });


    })
</script>
